<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // let arr = [1,2,3,4];

        // let obj = {
        //     name:"laowang",
        //     age:18,
        // }

        // // 常用
        // let json = {
        //     "name":"laowang",
        //     "age":18
        // }


        // set数据结构

        // [1,2,3,4]
        let arr = [1,2,3,4,1,2,3,123,123,1,1,1];

        // 数组去重
        let s1 = new Set(arr);
        console.log(arr);
        console.log(s1); //Set(4) {1, 2, 3, 4}

        // console.log(typeof s1);

        // 添加一条数据到set对象上
        s1.add(999);

        s1.delete(1);

        //清空
        // s1.clear();

        console.log(s1.keys());
        console.log(s1.values());
        console.log(s1.entries());


        console.log(s1);


        console.log(s1.has(666));

        s1.forEach((item)=>{
            console.log(item);
        })


        // 将set变成arr
        let newArr = [...new Set(arr)];

        console.log(newArr);


    </script>
</body>
</html>